package com.project.yuepai.controller.admin;

import com.project.yuepai.dto.MessageBean;
import com.project.yuepai.service.UserBaseService;
import com.project.yuepai.util.MessageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/admin/user")
public class UserController {

    @Autowired
    private UserBaseService userBaseService;

    /*
        获取用户展示相关信息
     */
    @RequestMapping(value = "/getUserAllInfos.action",method = RequestMethod.GET)
    public MessageBean getUserAllInfos(Integer limit, Integer page, Integer userRole,String nickName,String userPhone){
        return MessageUtil.success("获取成功！",userBaseService.getUserAllInfos(page,limit,userRole,nickName,userPhone));
    }

    /*
        删除用户
     */
    @RequestMapping(value = "/deleteUserAndRole.action",method = RequestMethod.DELETE)
    public MessageBean deleteUserAndRole(String userId,int userRole,int roleId){
        if(userBaseService.deleteUserAndRole(userId,userRole,roleId)==1)
            return MessageUtil.success("删除成功！");
        return MessageUtil.failure("删除失败！");
    }




}
